﻿using BBICMS.Application.ViewModels;
using BBICMS.Model.Security;
using BBICMS.Repository;
using System.Linq;
using System.Web.Mvc;

namespace BBICMS.WebUI.Areas.Admin.Controllers
{
    public class BaseController : Controller
    {
       public AjaxResultVM AR = new AjaxResultVM();
       public ApplicationUnit _unit = new ApplicationUnit();
      
        protected new virtual CustomPrincipal User => HttpContext.User as CustomPrincipal;

        protected string GetModelErrorMessage()
        {
            var validationErrors = string.Join("|",
                    ModelState.Values.Where(e => e.Errors.Count > 0)
                    .SelectMany(e => e.Errors)
                    .Select(e => e.ErrorMessage)
                    .ToArray());
            return validationErrors;
        }
    }
}